.class public Les/ff0;
.super Landroid/os/AsyncTask;
.source "FileWriter.java"


# annotations
.annotation system Ldalvik/annotation/MemberClasses;
    value = {
        Les/ff0$b;
    }
.end annotation

.annotation system Ldalvik/annotation/Signature;
    value = {
        "Landroid/os/AsyncTask<",
        "Ljava/lang/String;",
        "Ljava/lang/Void;",
        "Ljava/lang/Exception;",
        ">;"
    }
.end annotation


# instance fields
.field private final a:Ljava/lang/String;

.field private final b:Ljava/io/File;

.field private final c:Ljava/io/File;

.field private final d:Ljava/io/File;

.field private e:Lcom/jecelyin/editor/v2/ui/b;

.field private f:Les/ff0$b;

.field private g:Z

.field private final h:Ljava/lang/ref/WeakReference;
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "Ljava/lang/ref/WeakReference<",
            "Landroid/content/Context;",
            ">;"
        }
    .end annotation
.end field


# direct methods
.method public constructor <init>(Landroid/content/Context;Ljava/io/File;Ljava/io/File;Ljava/lang/String;Z)V
    .locals 0

    .line 1
    invoke-direct {p0}, Landroid/os/AsyncTask;-><init>()V

    const/4 p5, 0x0

    .line 2
    iput-boolean p5, p0, Les/ff0;->g:Z

    .line 3
    new-instance p5, Ljava/lang/ref/WeakReference;

    invoke-direct {p5, p1}, Ljava/lang/ref/WeakReference;-><init>(Ljava/lang/Object;)V

    iput-object p5, p0, Les/ff0;->h:Ljava/lang/ref/WeakReference;

    .line 4
    iput-object p2, p0, Les/ff0;->b:Ljava/io/File;

    .line 5
    iput-object p3, p0, Les/ff0;->d:Ljava/io/File;

    .line 6
    invoke-static {p2}, Les/ff0;->a(Ljava/io/File;)Ljava/io/File;

    move-result-object p1

    iput-object p1, p0, Les/ff0;->c:Ljava/io/File;

    .line 7
    iput-object p4, p0, Les/ff0;->a:Ljava/lang/String;

    return-void
.end method

.method private static a(Ljava/io/File;)Ljava/io/File;
    .locals 4

    .line 29
    new-instance v0, Ljava/io/File;

    invoke-virtual {p0}, Ljava/io/File;->getParent()Ljava/lang/String;

    move-result-object v1

    new-instance v2, Ljava/lang/StringBuilder;

    invoke-direct {v2}, Ljava/lang/StringBuilder;-><init>()V

    const-string v3, "."

    invoke-virtual {v2, v3}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    invoke-virtual {p0}, Ljava/io/File;->getName()Ljava/lang/String;

    move-result-object p0

    invoke-virtual {v2, p0}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    const-string p0, ".bak"

    invoke-virtual {v2, p0}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    invoke-virtual {v2}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object p0

    invoke-direct {v0, v1, p0}, Ljava/io/File;-><init>(Ljava/lang/String;Ljava/lang/String;)V

    return-object v0
.end method


# virtual methods
.method protected varargs a([Ljava/lang/String;)Ljava/lang/Exception;
    .locals 7

    const/4 v0, 0x0

    .line 4
    aget-object p1, p1, v0

    .line 5
    :try_start_0
    invoke-static {}, Lcom/jecelyin/editor/v2/utils/j;->a()Z

    move-result v1

    if-eqz v1, :cond_0

    iget-object v1, p0, Les/ff0;->b:Ljava/io/File;

    invoke-virtual {v1}, Ljava/io/File;->getAbsolutePath()Ljava/lang/String;

    move-result-object v1

    invoke-static {v1}, Lcom/jecelyin/editor/v2/b;->a(Ljava/lang/String;)Z

    move-result v1

    if-eqz v1, :cond_0

    const/4 v1, 0x1

    .line 6
    iput-boolean v1, p0, Les/ff0;->g:Z

    .line 7
    iget-object v1, p0, Les/ff0;->h:Ljava/lang/ref/WeakReference;

    invoke-virtual {v1}, Ljava/lang/ref/WeakReference;->get()Ljava/lang/Object;

    move-result-object v1

    check-cast v1, Landroid/app/Activity;

    iget-object v2, p0, Les/ff0;->b:Ljava/io/File;

    invoke-virtual {v2}, Ljava/io/File;->getAbsolutePath()Ljava/lang/String;

    move-result-object v2

    invoke-static {v1, v2}, Lcom/jecelyin/editor/v2/b;->a(Landroid/app/Activity;Ljava/lang/String;)Ljava/io/OutputStream;

    move-result-object v1

    goto :goto_0

    .line 8
    :cond_0
    new-instance v1, Ljava/io/FileOutputStream;

    iget-object v2, p0, Les/ff0;->b:Ljava/io/File;

    invoke-direct {v1, v2}, Ljava/io/FileOutputStream;-><init>(Ljava/io/File;)V

    .line 9
    :goto_0
    new-instance v2, Ljava/io/BufferedWriter;

    new-instance v3, Ljava/io/OutputStreamWriter;

    iget-object v4, p0, Les/ff0;->a:Ljava/lang/String;

    invoke-direct {v3, v1, v4}, Ljava/io/OutputStreamWriter;-><init>(Ljava/io/OutputStream;Ljava/lang/String;)V

    const/16 v1, 0x4000

    invoke-direct {v2, v3, v1}, Ljava/io/BufferedWriter;-><init>(Ljava/io/Writer;I)V

    new-array v3, v1, [C

    .line 10
    invoke-virtual {p1}, Ljava/lang/String;->length()I

    move-result v4

    if-lez v4, :cond_2

    const/4 v5, 0x0

    .line 11
    :goto_1
    invoke-static {v1, v4}, Ljava/lang/Math;->min(II)I

    move-result v1

    .line 12
    invoke-virtual {p1, v5, v1, v3, v0}, Ljava/lang/String;->getChars(II[CI)V

    sub-int v5, v1, v5

    .line 13
    invoke-virtual {v2, v3, v0, v5}, Ljava/io/BufferedWriter;->write([CII)V

    if-lt v1, v4, :cond_1

    goto :goto_2

    :cond_1
    add-int/lit16 v5, v1, 0x4000

    move v6, v5

    move v5, v1

    move v1, v6

    goto :goto_1

    .line 14
    :cond_2
    :goto_2
    invoke-virtual {v2}, Ljava/io/BufferedWriter;->close()V
    :try_end_0
    .catch Ljava/lang/Exception; {:try_start_0 .. :try_end_0} :catch_0

    .line 15
    iget-object p1, p0, Les/ff0;->d:Ljava/io/File;

    const/4 v0, 0x0

    if-eqz p1, :cond_6

    .line 16
    invoke-virtual {p1}, Ljava/io/File;->getAbsolutePath()Ljava/lang/String;

    move-result-object p1

    .line 17
    iget-object v1, p0, Les/ff0;->d:Ljava/io/File;

    invoke-virtual {v1}, Ljava/io/File;->canWrite()Z

    move-result v1

    if-eqz v1, :cond_4

    invoke-static {p1}, Lcom/jecelyin/editor/v2/b;->b(Ljava/lang/String;)Z

    move-result v1

    if-eqz v1, :cond_3

    goto :goto_3

    :cond_3
    move-object v1, v0

    goto :goto_4

    :cond_4
    :goto_3
    const-string v1, "rw"

    .line 18
    invoke-static {p1, v1}, Lcom/jecelyin/editor/v2/b;->a(Ljava/lang/String;Ljava/lang/String;)[Ljava/lang/String;

    move-result-object v1

    .line 19
    :goto_4
    iget-object v2, p0, Les/ff0;->b:Ljava/io/File;

    invoke-virtual {v2}, Ljava/io/File;->getAbsolutePath()Ljava/lang/String;

    move-result-object v2

    invoke-static {v2, p1}, Lcom/jecelyin/editor/v2/b;->b(Ljava/lang/String;Ljava/lang/String;)Z

    move-result p1

    if-eqz v1, :cond_5

    .line 20
    invoke-static {v1}, Lcom/jecelyin/editor/v2/b;->a([Ljava/lang/String;)Z

    :cond_5
    if-nez p1, :cond_6

    .line 21
    new-instance p1, Ljava/io/IOException;

    new-instance v0, Ljava/lang/StringBuilder;

    invoke-direct {v0}, Ljava/lang/StringBuilder;-><init>()V

    const-string v1, "Can\'t copy "

    invoke-virtual {v0, v1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    iget-object v1, p0, Les/ff0;->b:Ljava/io/File;

    invoke-virtual {v1}, Ljava/io/File;->getPath()Ljava/lang/String;

    move-result-object v1

    invoke-virtual {v0, v1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    const-string v1, " content to "

    invoke-virtual {v0, v1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    iget-object v1, p0, Les/ff0;->d:Ljava/io/File;

    invoke-virtual {v1}, Ljava/io/File;->getPath()Ljava/lang/String;

    move-result-object v1

    invoke-virtual {v0, v1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    invoke-virtual {v0}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v0

    invoke-direct {p1, v0}, Ljava/io/IOException;-><init>(Ljava/lang/String;)V

    return-object p1

    :cond_6
    return-object v0

    :catch_0
    move-exception p1

    .line 22
    iget-boolean v0, p0, Les/ff0;->g:Z

    if-eqz v0, :cond_7

    .line 23
    iget-object v0, p0, Les/ff0;->e:Lcom/jecelyin/editor/v2/ui/b;

    if-eqz v0, :cond_7

    .line 24
    invoke-virtual {v0}, Lcom/jecelyin/editor/v2/ui/b;->d()Lcom/jecelyin/editor/v2/ui/JeEditorActivity;

    move-result-object p1

    sget v0, Lcom/jecelyin/editor/v2/m;->je_hint_grant_auth_msg:I

    invoke-virtual {p1, v0}, Landroid/app/Activity;->getString(I)Ljava/lang/String;

    move-result-object p1

    .line 25
    new-instance v0, Ljava/lang/Exception;

    invoke-direct {v0, p1}, Ljava/lang/Exception;-><init>(Ljava/lang/String;)V

    return-object v0

    :cond_7
    return-object p1
.end method

.method public a(Lcom/jecelyin/editor/v2/ui/b;)V
    .locals 1

    .line 1
    iput-object p1, p0, Les/ff0;->e:Lcom/jecelyin/editor/v2/ui/b;

    .line 2
    new-instance v0, Les/ff0$a;

    invoke-direct {v0, p0}, Les/ff0$a;-><init>(Les/ff0;)V

    invoke-virtual {p1, v0}, Lcom/jecelyin/editor/v2/ui/b;->b(Lcom/jecelyin/editor/v2/widget/text/c;)V

    return-void
.end method

.method public a(Les/ff0$b;)V
    .locals 0

    .line 3
    iput-object p1, p0, Les/ff0;->f:Les/ff0$b;

    return-void
.end method

.method protected a(Ljava/lang/Exception;)V
    .locals 1

    .line 26
    iget-object v0, p0, Les/ff0;->f:Les/ff0$b;

    if-nez v0, :cond_0

    return-void

    :cond_0
    if-nez p1, :cond_1

    .line 27
    invoke-interface {v0}, Les/ff0$b;->onSuccess()V

    goto :goto_0

    .line 28
    :cond_1
    invoke-interface {v0, p1}, Les/ff0$b;->onError(Ljava/lang/Exception;)V

    :goto_0
    return-void
.end method

.method protected bridge synthetic doInBackground([Ljava/lang/Object;)Ljava/lang/Object;
    .locals 0

    .line 1
    check-cast p1, [Ljava/lang/String;

    invoke-virtual {p0, p1}, Les/ff0;->a([Ljava/lang/String;)Ljava/lang/Exception;

    move-result-object p1

    return-object p1
.end method

.method protected bridge synthetic onPostExecute(Ljava/lang/Object;)V
    .locals 0

    .line 1
    check-cast p1, Ljava/lang/Exception;

    invoke-virtual {p0, p1}, Les/ff0;->a(Ljava/lang/Exception;)V

    return-void
.end method
